package com.whitedust.top90;

import com.whitedust.structure.TreeNode;

/**
 *
 * @author A
 * @since 2025/11/16 21:05
 */

public class Top90 {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root == null) return false;
        targetSum -= root.val;
        if (targetSum == 0 && root.left == null && root.right == null) return true;
        boolean left = hasPathSum(root.left, targetSum);
        boolean right = hasPathSum(root.right, targetSum);
        return left || right;
    }

}
